/*     */ package com.qmsk.business.member.memberCar.controller;
/*     */ 
/*     */ import com.qmsk.business.member.memberCar.dao.MemberCarDAO;
/*     */ import com.qmsk.business.member.memberCar.params.MemberCarOpt;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/memberCar"})
/*     */ public class MemberCarController
/*     */ {
/*  40 */   private static final Logger logger = Logger.getLogger(MemberCarController.class);
/*     */ 
/*     */   @Autowired
/*     */   private MemberCarDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */     throws SQLException
/*     */   {
/*  59 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  61 */       MemberCarOpt c = new MemberCarOpt();
/*  62 */       c.setShopId(shopId);
/*  63 */       GsonEbRst gsonEbRst = this.dao.getListOfShopIdOpt(c.getMapList(), nPageIdx, 
/*  64 */         nPageSize);
/*  65 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  67 */       logger.error(e);
/*  68 */       ResponseUtils.setErrorMsgResponse(
/*  69 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/opt1/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfOpt1(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Long shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */     throws SQLException
/*     */   {
/*  87 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*  88 */     Map params = new HashMap();
/*     */ 
/*  90 */     MapUtils.addToMap(params, "shopId", shopId);
/*     */ 
/*  92 */     MapUtils.addPercentToMap(params, "tel", RequestUtils.getString(request, "tel"));
/*  93 */     MapUtils.addPercentToMap(params, "mp", RequestUtils.getString(request, "mp"));
/*  94 */     MapUtils.addPercentToMap(params, "custName", RequestUtils.getString(request, "custName"));
/*  95 */     MapUtils.addToMap(params, "status", RequestUtils.getInt(request, "status"));
/*     */     try {
/*  97 */       GsonEbRst gsonEbRst = this.dao.getListOfShopIdOpt(params, nPageIdx, 
/*  98 */         nPageSize);
/*  99 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 101 */       logger.error(e);
/* 102 */       ResponseUtils.setErrorMsgResponse(
/* 103 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/car/custId/{custId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListCarOfCustId(HttpServletRequest request, HttpServletResponse response, @PathVariable("custId") Integer custId)
/*     */     throws SQLException
/*     */   {
/*     */     try
/*     */     {
/* 118 */       GsonEbRst gsonEbRst = this.dao.getGsonOfCarCustId(custId);
/* 119 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 121 */       logger.error(e);
/* 122 */       ResponseUtils.setErrorMsgResponse(
/* 123 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/car/license/{license}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListCarOfLicense(HttpServletRequest request, HttpServletResponse response, @PathVariable("license") String license)
/*     */     throws SQLException
/*     */   {
/*     */     try
/*     */     {
/* 138 */       GsonEbRst gsonEbRst = this.dao.getGsonOfCarLicense(license);
/* 139 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 141 */       logger.error(e);
/* 142 */       ResponseUtils.setErrorMsgResponse(
/* 143 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/car/carId/{carId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListCarOfCarId(HttpServletRequest request, HttpServletResponse response, @PathVariable("carId") Integer carId)
/*     */     throws SQLException
/*     */   {
/*     */     try
/*     */     {
/* 158 */       GsonEbRst gsonEbRst = this.dao.getGsonOfCarId(carId);
/* 159 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 161 */       logger.error(e);
/* 162 */       ResponseUtils.setErrorMsgResponse(
/* 163 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/custId/{custId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfCustId(HttpServletRequest request, HttpServletResponse response, @PathVariable("custId") Integer custId)
/*     */   {
/*     */     try
/*     */     {
/* 177 */       GsonEbRst gsonEbRst = this.dao.getGsonOfCustId(custId);
/* 178 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 180 */       logger.error(e);
/* 181 */       ResponseUtils.setErrorMsgResponse(
/* 182 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/List"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insertList(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 194 */     String sJson = RequestUtils.getString(request, "data");
/* 195 */     int nUpdates = -1;
/*     */     try {
/* 197 */       this.dao.deleteListPk(sJson);
/* 198 */       nUpdates = this.dao.insertList(sJson);
/* 199 */       ResponseUtils.setSqlResultResponse(nUpdates, 
/* 200 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 201 */         response);
/*     */     } catch (SQLException e) {
/* 203 */       logger.error(e);
/* 204 */       ResponseUtils.setSqlResultResponse(nUpdates, 
/* 205 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 206 */         response);
/*     */     } finally {
/* 208 */       if (nUpdates <= -1)
/* 209 */         DbConnection.rollback();
/*     */       else
/* 211 */         DbConnection.commit();
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"delete/List"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void deleteList(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 224 */     int nUpdates = -1;
/* 225 */     String sJson = RequestUtils.getStringOfId(request);
/*     */     try {
/* 227 */       nUpdates = this.dao.deleteList(sJson);
/* 228 */       DbConnection.commit();
/* 229 */       ResponseUtils.setSqlResultResponse(nUpdates, 
/* 230 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 231 */         response);
/*     */     } catch (SQLException e) {
/* 233 */       DbConnection.rollback();
/* 234 */       logger.error(e);
/* 235 */       ResponseUtils.setErrorMsgResponse(
/* 236 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 237 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response) {
/* 244 */     String sGsonInData = request.getParameter("data");
/* 245 */     int nResult = 0;
/*     */     try {
/* 247 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 248 */       if (g == null)
/* 249 */         ResponseUtils.setErrorMsgResponse(
/* 250 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 251 */           response);
/*     */       else {
/* 253 */         nResult = this.dao.updateJsonOneRow(g);
/*     */       }
/* 255 */       DbConnection.commit();
/*     */ 
/* 257 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 258 */         RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request), 
/* 259 */         response);
/*     */     } catch (Exception e) {
/* 261 */       DbConnection.rollback();
/* 262 */       logger.error(e);
/* 263 */       ResponseUtils.setErrorMsgResponse(
/* 264 */         RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request) + 
/* 265 */         ":" + e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.member.memberCar.controller.MemberCarController
 * JD-Core Version:    0.5.3
 */